<?xml version = "1.0"?>

<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" 
   version = "1.0">

<xsl:output method = "xml" omit-xml-declaration = "no" 
   indent = "yes" doctype-system = 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
   doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN"/>

<!-- XSL document that transforms XML into XHTML -->

<!-- specify the root of the XML document -->
<!-- that references this stylesheet      -->
<xsl:template match = "employee">

   <html xmlns = "http://www.w3.org/1999/xhtml"> 
   
   <head>

      <title>Add new employee</title>

      <link rel = "stylesheet" href = "styles.css" 
         type = "text/css" />
   </head>

   <body>
      <p class = "bigFont"><xsl:value-of select = "ename"/></p>

   <form method = "post" action = "addNewPersonServlet">
      <table>
        <thead>
            <th style = "width: 200px">empno</th>
            <th style = "width: 200px">mgr</th>
            <th style = "width: 200px">deptno</th>
            <th style = "width: 200px">ename</th>
        </thead>

         <tr>
            <td>
            </td>
            <td>
                <select name="mgr">
                    <xsl:for-each select="mgr"> 
                        <option>
                            <xsl:if test="@selected='true'">
                                <xsl:attribute name="selected"/>
                            </xsl:if >
                            <xsl:attribute name="value"><xsl:value-of select="@id"/></xsl:attribute>
                            <xsl:value-of select="@name"/>
                        </option>
                    </xsl:for-each> 
                </select>
            </td>

            <td>
                <select name="deptno">
                    <xsl:for-each select="deptno"> 
                        <option>
                            <xsl:if test="@selected='true'">
                                <xsl:attribute name="selected"/>
                            </xsl:if >
                            <xsl:attribute name="value"><xsl:value-of select="@id"/></xsl:attribute>
                            <xsl:value-of select="@name"/>
                        </option>
                    </xsl:for-each> 
                </select>
            </td>

            <td>
                <input type="text" name="ename">
                    <xsl:attribute name="value"><xsl:value-of select="ename" /></xsl:attribute>
                </input>
            </td>
         </tr>

      </table>

      <table>
        <thead>
            <th style = "width: 200px">job</th>
            <th style = "width: 200px">sal</th>
            <th style = "width: 200px">comm</th>
            <th style = "width: 200px">hiredate</th>
        </thead>

         <tr>
            <td>
                <input type="text" name="job">
                    <xsl:attribute name="value"><xsl:value-of select="job" /></xsl:attribute>
                </input>
            </td>
            <td>
                <input type="text" name="sal">
                    <xsl:attribute name="value"><xsl:value-of select="sal" /></xsl:attribute>
                </input>
            </td>
            <td>
                <input type="text" name="comm">
                    <xsl:attribute name="value"><xsl:value-of select="comm" /></xsl:attribute>
                </input>
            </td>
            <td>
                <input type="date" name="hiredate">
                    <xsl:attribute name="value"><xsl:value-of select="hiredate" /></xsl:attribute>
                </input>
            </td>
         </tr>

      </table>

      <p>
        <input type = "submit" name = "Apply" value = "Add new employee" />
        <input type = "reset" name = "Discard" value = "Discard changes" />
      </p>
   </form>
        <p>
            <a href = "Hierarchy.jsp">View hierarchy list</a>
            <!--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-->
            <a href = "SimpleTable.jsp">View as simple table</a>
        </p>
   </body>

   </html> 

</xsl:template>

</xsl:stylesheet>
